#ifndef ALGORITHMSTRATEGY_H
#define ALGORITHMSTRATEGY_H

#include <QPixmap>
#include <QString>
#include <QMap>
#include <QDebug>
#include <QObject>
#include <opencv2/opencv.hpp>
using namespace cv;

class AlgorithmStrategy:public QObject
{
    Q_OBJECT
public:
    virtual void methodAS(Mat& mask, QPixmap* m_tmpPic, QPixmap* m_pic) = 0;

protected:
    QString m_name;     // 算法名字
};

class BinaryAS: public AlgorithmStrategy
{
public:
    BinaryAS(const QString& name);
    virtual void methodAS(Mat& mask, QPixmap* m_tmpPic, QPixmap* m_pic);
    void setThreshold(int threshold);
    void setMaxValue(int max);
    void setName(const QString& name);

private:
    QMap<QString, int> m_hash;
    int m_threshold = 0;
    int m_maxValue = 255;
};

// 形态学
class MorphologicalAS: public AlgorithmStrategy
{
public:
    MorphologicalAS(const QString& name, const QString& shape, int kernel);
    virtual void methodAS(Mat& mask, QPixmap* m_tmpPic, QPixmap* m_pic) override;
    void setKernel(int kernel);
    void setShape(const QString& shape);

private:
    QMap<QString, int> m_hash;
    QString m_shape;            // 形状
    Size m_kernel;
};

// 滤波
class FilteringAS: public AlgorithmStrategy
{
public:
    FilteringAS(const QString& name);
    virtual void methodAS(Mat& mask, QPixmap* m_tmpPic, QPixmap* m_pic) override;
    void setKernel(int kernel);

private:
    Size m_kernel;
};

// 边缘检测
class EdgeDetectionAS: public AlgorithmStrategy
{
public:
    EdgeDetectionAS(const QString& name);
    virtual void methodAS(Mat& mask, QPixmap* m_tmpPic, QPixmap* m_pic) override;
};

// 直方图均衡化
class EqualizeHistAS: public AlgorithmStrategy
{
public:
    EqualizeHistAS(const QString& name);
    virtual void methodAS(Mat& mask, QPixmap* m_tmpPic, QPixmap* m_pic) override;
};

// 彩色图像格式转换
class ColorToAS: public AlgorithmStrategy
{
public:
    ColorToAS(const QString& name);
    virtual void methodAS(Mat& mask, QPixmap* m_tmpPic, QPixmap* m_pic) override;
};

#endif // ALGORITHMSTRATEGY_H
